package com.azkj.album.adapter;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;

import com.azkj.album.R;
import com.azkj.album.dto.BackGroundListBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

public class BackGroundListAdapter extends BaseQuickAdapter<BackGroundListBean, BaseViewHolder> {
    private Context mContext;
    private ItemOnClickInterface itemOnClickInterface;

    public int singlePosition = -1;
    public BackGroundListAdapter(Context context, int layoutResId) {
        super(layoutResId);
        mContext = context;
    }

    //回调接口
    public interface ItemOnClickInterface {
        void onItemClick(int postation);
    }

    //定义回调方法
    public void setItemOnClickInterface(ItemOnClickInterface itemOnClickInterface) {
        this.itemOnClickInterface = itemOnClickInterface;
    }

    @Override
    protected void convert(BaseViewHolder helper, BackGroundListBean item) {
        ImageView image = helper.getView(R.id.iv_image);
        Glide.with(mContext).load(item.getImage()).into(image);
        ImageView image_select = helper.getView(R.id.iv_image_select);
        if (item.isSelect()) {
            image_select.setBackgroundResource(R.mipmap.ic_new_photo_yes_select);
        } else {
            image_select.setBackgroundResource(R.mipmap.ic_new_photo_no_select);
        }
    }
}
